import 'dart:convert' as convert;
import 'package:http/http.dart' as http;
import 'package:date_format/date_format.dart';

void main(List<String> arguments) async {
  var url = Uri.https('www.jianshu.com', '/shakespeare/v2/notes/recommend');
  // Uri.https('www.googleapis.com', '/books/v1/volumes', {'q': '{http}'});

  // Await the http get response, then decode the json-formatted response.
  var response = await http.get(url);
  if (response.statusCode == 200) {
    var jsonResponse =
        convert.jsonDecode(response.body) as Map<String, dynamic>;
    // var itemCount = jsonResponse['totalItems'];
    print(jsonResponse);
  } else {
    print('Request failed with status: ${response.statusCode}.');
  }

  print(formatDate(DateTime(1989, 2, 21), [yyyy, '-', mm, '-', dd]));
}
